<?php
/**
 * This file is part of PHPlaza (http://code.google.com/p/phplaza)
 * This file is licensed under the GNU Lesser General Public License
 *      http://www.gnu.org/licenses/lgpl.html
 *
 * No warranty is given, express or implied. Use at your own risk.
 */

namespace core::collections;
abstract class TreeIterator implements IteratorAggregate
{
 	protected $list;
	
	public function __construct(ITreeItem $rootNode)
	{
		$this->list = new CList();		
		$this->prepareList($rootNode);
	}
	
	abstract protected function prepareList($node);
	
	public function getIterator()
	{
		return $this->list->getIterator();
	}
	
	public static function getPrefixIterator(ITreeItem $rootNode)
	{
		return new PrefixIterator($rootNode);
	}
	
	public static function getPostfixIterator(ITreeItem $rootNode)
	{
		return new PostfixIterator($rootNode);
	}
}